home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Archive / Games / Soundboard / CAttachment.cp next >
Encoding:
Text File  |  2000-09-28  |  2.3 KB  |  85 lines  |  [TEXT/MMCC]

  1. // ===========================================================================
  2. //    CAttachment.cp                ©1995 Apple Computer, Inc. All rights reserved.
  3. // ===========================================================================
  4. //
  5. //    Misc attachments
  6. //
  7.  
  8. #include "CAttachment.h"
  9.  
  10.  
  11. // ===========================================================================
  12. // • C3DBorderAttachment                                 C3DBorderAttachment •
  13. // ===========================================================================
  14. //    Draws a 3D chisseled border within the Frame of a Pane
  15. //        For use only with msg_DrawOrPrint
  16.  
  17. C3DBorderAttachment::C3DBorderAttachment(void)
  18.         : LAttachment(msg_DrawOrPrint, true)
  19. {
  20. }
  21.  
  22.  
  23. void
  24. C3DBorderAttachment::ExecuteSelf(
  25.     MessageT    /* inMessage */,
  26.     void        *ioParam)
  27. {
  28.     StColorPenState    savePenState;        // Will save and restore pen state
  29.     Rect            *frame = (Rect *)ioParam, erase = *frame;
  30.     
  31.  
  32.     ::PenNormal();
  33.     
  34.     ::InsetRect (frame, 1, 1 );
  35.     ::FrameRect (frame);
  36.     ::InsetRect (frame, -1, -1);
  37.     ::InsetRect (&erase, 2, 2);
  38.         
  39.     StDeviceLoop    theLoop(*frame);    // Set up for looping thru each device
  40.     Int16    depth;
  41.     
  42.     while (theLoop.NextDepth(depth)) {
  43.     
  44.             // At this point, the clipping region is set to the portion
  45.             // of the Pane that is on the screen with the current
  46.             // bit depth. Therefore, we can just draw everything, and
  47.             // let the clipping region restrict the drawing.
  48.             //
  49.             // If you are interested in other characteristics of the
  50.             // current screen device, you can call theLoop.GetCurrentDevice
  51.             // which will return a GDHandle.
  52.  
  53.         if (depth >= 4) {
  54.  
  55.                 // When there are at least 16 colors, draw the 3D chissel effect
  56.                 
  57.             StColorState    colorSaver;    // Constructor saves fore and back
  58.                                         // colors; Destructor restores them
  59.             RGBColor        white = {0xffff, 0xffff, 0xffff}, dkGrey = {0x5555, 0x5555, 0x5555},
  60.                             ltGrey = {0xCCCC, 0xCCCC, 0xCCCC};
  61.             
  62.             ::RGBBackColor(&white);
  63.             ::EraseRect (&erase);
  64.  
  65.             ::RGBForeColor(&dkGrey);
  66.             ::MoveTo(frame->left, frame->bottom-1);
  67.             ::LineTo(frame->left, frame->top);
  68.             ::LineTo(frame->right-1, frame->top);
  69.             
  70.             ::RGBForeColor(<Grey);
  71.             ::MoveTo(frame->left+1, frame->bottom-1);
  72.             ::LineTo(frame->right-1, frame->bottom-1);
  73.             ::RGBForeColor(&white);
  74.             ::LineTo(frame->right-1, frame->top+1);
  75.         }
  76.         else ::EraseRect (&erase);
  77.     }
  78. }
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.